#!/usr/bin/perl -w
# compact mysql schema so there's exactly 1 full query per line
# otherwise QSqlQuery can't execute it

open(FILE,"<mysql.schema") || die("Can't open input file!\n");

$output = "";
$str = "";
while(<FILE>){
	chop;
	if (/^CREATE TABLE/){
		$stage = 1;
	}
	elsif (/^\) /){
		$stage = 0;
		$output .= $str.");\n";
		$str = "";
	}
	if($stage){
		$str .= $_;
	}
}
close(FILE);

$output =~ s/ {2,}/ /g;

open(FILE,">mysql.schema") || die("Can't open output file!\n");
print FILE $output;
close(FILE);
